package com.ruoyi.system.service.impl;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.ConsumptionRecordMapper;
import com.ruoyi.system.domain.ConsumptionRecord;
import com.ruoyi.system.service.IConsumptionRecordService;
import com.ruoyi.common.core.text.Convert;

/**
 * 消费记录Service业务层处理
 * 
 * @author 华馨悦
 * @date 2025-01-24
 */
@Service
public class ConsumptionRecordServiceImpl extends ServiceImpl<ConsumptionRecordMapper,ConsumptionRecord> implements IConsumptionRecordService

{
    @Autowired
    private ConsumptionRecordMapper consumptionRecordMapper;

    /**
     * 查询消费记录
     * 
     * @param id 消费记录主键
     * @return 消费记录
     */
    @Override
    public ConsumptionRecord selectConsumptionRecordById(Long id)
    {
        return consumptionRecordMapper.selectConsumptionRecordById(id);
    }

    /**
     * 查询消费记录列表
     * 
     * @param consumptionRecord 消费记录
     * @return 消费记录
     */
    @Override
    public List<ConsumptionRecord> selectConsumptionRecordList(ConsumptionRecord consumptionRecord)
    {
        return consumptionRecordMapper.selectConsumptionRecordList(consumptionRecord);
    }

    /**
     * 新增消费记录
     * 
     * @param consumptionRecord 消费记录
     * @return 结果
     */
    @Override
    public int insertConsumptionRecord(ConsumptionRecord consumptionRecord)
    {
        return consumptionRecordMapper.insertConsumptionRecord(consumptionRecord);
    }

    /**
     * 修改消费记录
     * 
     * @param consumptionRecord 消费记录
     * @return 结果
     */
    @Override
    public int updateConsumptionRecord(ConsumptionRecord consumptionRecord)
    {
        return consumptionRecordMapper.updateConsumptionRecord(consumptionRecord);
    }

    /**
     * 批量删除消费记录
     * 
     * @param ids 需要删除的消费记录主键
     * @return 结果
     */
    @Override
    public int deleteConsumptionRecordByIds(String ids)
    {
        return consumptionRecordMapper.deleteConsumptionRecordByIds(Convert.toStrArray(ids));
    }

    /**
     * 批量软删除消费记录
     *
     * @param ids 需要软删除的消费记录主键
     * @return 结果
     */
    @Override
    public int softDeleteConsumptionRecordByIds(String ids)
    {
        String[] strArray = Convert.toStrArray(ids);
        int count = 0;
        for (String s : strArray) {
            ConsumptionRecord consumptionRecord = consumptionRecordMapper.selectConsumptionRecordById(Long.valueOf(s));
            consumptionRecord.setIsDelete(1);
            int i = consumptionRecordMapper.updateConsumptionRecord(consumptionRecord);
            count = count + i;
        }
        return count;
    }

    /**
     * 删除消费记录信息
     * 
     * @param id 消费记录主键
     * @return 结果
     */
    @Override
    public int deleteConsumptionRecordById(Long id)
    {
        return consumptionRecordMapper.deleteConsumptionRecordById(id);
    }
}
